<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form id="form" style="justify-items:center">
    <div style= margin-left:100px>
        <Text>填写表单</Text></br>
        <input id="formName">formName</input></br>
        <input id="title_">title_</input></br>
        <input id="emergency_">emergency_</input></br>
        <input id="trackId">trackId</input></br>
        <button style="margin-top:20px" type="button" id="det">确定</button>
    </div>
</form>
</body>

<script type="text/javascript" src="./swagger/lib/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
    var form_table = "";
    var title_ = "";
    var emergency_ = "";
    var trackId = "";


    var paramstr =window.location.search.substr(1);
    trackId = paramstr.split("=")[1];
    console.log("trackId"+trackId);
    $("#trackId").attr("value",trackId);
    init();

    function init(){
        $.ajax({
            url: "http://localhost:9999/ocndy/sys/form/queryForm",

            dataType: "json",
            type: "post",
            data: paramstr,

            success: function (result) {
                form_table = result.data.form_table;
                title_ = result.data.title_;
                emergency_ = result.data.emergency_;
                trackId = result.data.trackId;
                // alert(JSON.stringify(result))
                if("" != form_table){
                    $("#formName").attr("value",form_table);
                    $("#title_").attr("value",title_);
                    $("#emergency_").attr("value",emergency_);
                }
            },
            error: function (data) {
                alert("err"+JSON.stringify(result))
            }
        });
    }

    $("#name").attr("value","lee");

    $("#det").click(function () {
        var formData = {
            "formName": $("#formName").val(),
            "formId": "1",
            "trackId": $("#trackId").val(),
            "title_": $("#title_").val(),
            "emergency_": $("#emergency_").val()
        }
        $.ajax({
            url: "http://localhost:9999/ocndy/sys/form/fillForm",

            dataType: "json",
            type: "post",
            data: formData,

            success: function (result) {
                alert(result.msg);
            },
            error: function (data) {
                alert("请求出错");
            }
        });
    });
</script>
</html>